package com.boil.qz.safekavass.web.request.param;

import com.boil.util.Constants;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * Created by ChenYong on 2017-08-07.
 * <br>
 * 更新角色的请求参数。
 */
public class RoleUpdateParam extends IdParam {
    /**
     * 角色名称
     */
    @NotBlank(message = "角色名称不能为空")
    @Length(min = Constants.VALUE_1, max = Constants.VALUE_50, message = "角色名称的长度在1至50个字之间")
    @Pattern(regexp = Constants.CHINESE_2_RE, message = "角色名称由汉字、数字（0-9）、字母（a-z, A-Z）、下划线（_）、斜杠（/）组成")
    private String roleName;
    /**
     * 角色代码
     */
    @NotBlank(message = "角色代码不能为空")
    @Length(min = Constants.VALUE_1, max = Constants.VALUE_50, message = "角色代码的长度在1至50个字符之间")
    @Pattern(regexp = Constants.ROLE_RE, message = Constants.ROLE_RE_MSG)
    private String roleCode;
    /**
     * 资源 ID 拼接的字符串
     */
    @NotNull(message = "资源ID拼接的字符串不能为空")
    @Pattern(regexp = Constants.NUMBER_STR_SPLIT_RE, message = "资源ID拼接的字符串格式不正确")
    private String resourceIds;

    /**
     * 默认构造器
     */
    public RoleUpdateParam() {
        super();
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleCode() {
        return roleCode;
    }

    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }

    public String getResourceIds() {
        return resourceIds;
    }

    public void setResourceIds(String resourceIds) {
        this.resourceIds = resourceIds;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("RoleUpdateParam{");
        sb.append("roleName='").append(roleName).append('\'');
        sb.append(", roleCode='").append(roleCode).append('\'');
        sb.append(", resourceIds='").append(resourceIds).append('\'');
        sb.append(", id=").append(id);
        sb.append('}');
        return sb.toString();
    }
}